import QtQuick 2.12
import QtQuick.Window 2.12
import QtLocation       5.12
import QtPositioning    5.12

//import MyModule 1.0

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")
    Component.onCompleted: {
        console.log(_map.supportedMapTypes[0].name)
        _map.activeMapType = _map.supportedMapTypes[0]
    }
    Rectangle{
        id:titleRect
        color:"red"
        anchors.top: parent.top
        height: 50
        width: parent.width
        Row{
            spacing: 10
            Rectangle{
                width: 100
                height: 50
                Text {
                    text: qsTr("在线地图")
                    anchors.centerIn: parent
                }
                MouseArea{
                    anchors.fill: parent
                    onClicked: {
                        _map.visible = true;
                        _offlineMap.visible = false;
                    }
                }
            }

            Rectangle{
                width: 100
                height: 50
                Text {
                    text: qsTr("下载地图")
                    anchors.centerIn: parent
                }
                MouseArea{
                    anchors.fill: parent
                    onClicked: {
                        _map.visible = false;
                        _offlineMap.visible = true;
                    }
                }
            }
        }
    }
    Rectangle{
        id:mapRect
        anchors.top: titleRect.bottom
        anchors.bottom: parent.bottom
        width:parent.width
        Map {
            id: _map
            anchors.fill: parent
            gesture.acceptedGestures:   MapGestureArea.PinchGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture
            gesture.flickDeceleration:  3000
            minimumZoomLevel: 3
            maximumZoomLevel: 20
            zoomLevel: 10
            center: QtPositioning.coordinate(30.67, 104.06)
            plugin:                     Plugin { name: "QGroundControl" }
        }

         OfflineMap{
             id:_offlineMap
             visible: false
         }
    }


}
